#   SCE CONFIDENTIAL
#   PLAYSTATION(R)3 Programmer Tool Runtime Library 192.001
#   Copyright (C) 2007 Sony Computer Entertainment Inc.
#   All Rights Reserved.
#

#-------------------------------

ifeq ($(shell uname), Linux)
    CELL_HOST_PATH  = $(CELL_SDK)/host-linux
    CELL_DATA_DIR   ?= $(CELL_SDK)/sample_data
    EXE_SUFFIX      =
else
    CELL_HOST_PATH  = $(CELL_SDK)/host-win32
	# delete drive letter
	CELL_DATA_DIR   ?= $(shell echo $(CELL_SDK) | sed s/^.://)/sample_data
	EXE_SUFFIX      = .exe
endif

CELL_TARGET_PATH    = $(CELL_SDK)/target

CELL_HOST_BIN_PATH  = $(CELL_HOST_PATH)/bin

ifeq ($(shell test -f /bin/install && echo 1),1)
	INSTALL         = /bin/install
else
	INSTALL         = /usr/bin/install
endif

ifeq ($(shell test -f /bin/find && echo 1),1)
	FIND            = /bin/find
else
	FIND            = /usr/bin/find
endif

ifeq ($(shell test -f /bin/sort && echo 1),1)
	SORT            = /bin/sort
else
	SORT            = /usr/bin/sort
endif

CP                  = /bin/cp
RM                  = /bin/rm -f
PERL                = /usr/bin/perl
ECHO                = @echo

OBJS_DIR            ?= objs

CELL_SAMPLE_DIR     ?= $(CELL_SDK)/samples
CELL_FW_DIR         ?= $(CELL_SAMPLE_DIR)/fw
CELL_FWGCM_DIR      ?= $(CELL_SAMPLE_DIR)/gcm/fwgcm
CELL_EXTLIBS_DIR    ?= $(CELL_SAMPLE_DIR)/external-libs
CELL_COMMON_DIR     ?= $(CELL_SAMPLE_DIR)/common

# CELL_GPU_TYPE (currently RSX is only one option)
CELL_GPU_TYPE       ?= RSX

# CELL_PSGL_VERSION is debug, dpm or opt
CELL_PSGL_VERSION   ?= debug

# CELL_DISPLAY_MODE (default: 720p)
CELL_DISPLAY_MODE   ?= 720p

MAKE_FSELF          = $(CELL_HOST_PATH)/bin/make_fself$(EXE_SUFFIX)
MAKE_FSELF_NPDRM    = $(CELL_HOST_PATH)/bin/make_fself_npdrm$(EXE_SUFFIX)
MAKE_EDATA_NPDRM    = $(CELL_HOST_PATH)/bin/make_edata_npdrm$(EXE_SUFFIX)
MAKE_PACKAGE_NPDRM  = $(CELL_HOST_PATH)/bin/make_package_npdrm$(EXE_SUFFIX)

FSELF_SUFFIX        = .self
SPRX_SUFFIX         = .sprx

#----------------------------------------------------------------------
# default target
#----------------------------------------------------------------------
.PHONY : all

all:

#----------------------------------------------------------------------
# warning flags
#----------------------------------------------------------------------

CSTDFLAGS			= -std=c99
CXXSTDFLAGS			= -std=c++98

WARNFLAGS_UNINITIALIZED		= -Wuninitialized
WARNFLAGS_UNSUPPORTED		= -Wpadded
WARNFLAGS_UNRECOMMENDED		= -Wconversion

# warning flags for c++

# warning: L1, L2 (default), L3 or L4
CXXWARNFLAGS_L1 = \
	-W \
	-Wall

CXXWARNFLAGS_L2 = \
	$(CXXWARNFLAGS_L1) \
	$(WARNFLAGS_UNINITIALIZED) \
	-Wcomment \
	-Wchar-subscripts \
	-Wdeprecated-declarations \
	-Wendif-labels \
	-Wformat=2 \
	-Wformat-extra-args \
	-Wimplicit \
	-Wimport \
	-Winline \
	-Wmissing-braces \
	-Wparentheses \
	-Wpointer-arith \
	-Wredundant-decls \
	-Wreturn-type \
	-Wshadow \
	-Wsign-compare \
	-Wswitch \
	-Wunknown-pragmas \
	-Wunused \
	-Wwrite-strings

CXXWARNFLAGS_L3 = \
	$(CXXWARNFLAGS_L2) \
	-Wswitch-default \
	-Wswitch-enum \
	-Wfloat-equal \
	-Wpacked

CXXWARNFLAGS_L4 = \
	$(CXXWARNFLAGS_L3) \
	-Waggregate-return \
	-Wunreachable-code

# warning flags for C

C_ONLY_WARNFLAGS = \
	-Wmain \
	-Wbad-function-cast \
	-Wmissing-declarations \
	-Wnested-externs \
	-Wstrict-prototypes \
	-Wmissing-prototypes

CWARNFLAGS_L1 = $(CXXWARNFLAGS_L1)
CWARNFLAGS_L2 = $(CXXWARNFLAGS_L2) $(C_ONLY_WARNFLAGS)
CWARNFLAGS_L3 = $(CXXWARNFLAGS_L3)
CWARNFLAGS_L4 = $(CXXWARNFLAGS_L4) -pedantic

ASFLAGS = -xassembler-with-cpp

#----------------------------------------------------------------------
# include sdk.makedef-*.mk
#----------------------------------------------------------------------

include $(CELL_MK_DIR)/sdk.makedef-mk.mk
include $(CELL_MK_DIR)/sdk.makedef-ppu.mk
include $(CELL_MK_DIR)/sdk.makedef-prx.mk
include $(CELL_MK_DIR)/sdk.makedef-spu.mk
include $(CELL_MK_DIR)/sdk.makedef-cg.mk

